package main

import "fmt"

func main() {
	var shaper Shaper
	shaper = Square{10}
	area := shaper.Area()
	fmt.Println("area is :", area)

	shaper = Rectangle{5, 10}
	area2 := shaper.Area()
	fmt.Println("area2 is :", area2)
}

// 定义形式接口
type Shaper interface {
	Area() float64
}

// 定义正方形结构体
type Square struct {
	Side float64
}

func (square Square) Area() float64 {
	return square.Side * square.Side
}

// 定义长方形结构体
type Rectangle struct {
	Width float64
	Length float64
}

func (receiver Rectangle) Area() float64 {
	return receiver.Length * receiver.Width
}

